﻿@model _2_1_2015_WSite.Models.UserViewModel
@{
    ViewBag.Title = "AddUpdateUser";
}

<center>
    <div class="box box-info" style="padding: 15px; width:40%; margin:25px">
        <h2>Update/Create User</h2>
        @using (Html.BeginForm())
        {

            <div class="form-group">
                @Html.LabelFor(u => u.FirstName)
                @Html.TextBoxFor(u => u.FirstName, new { @class = "form-control" })
            </div>


            <div class="form-group">
                @Html.LabelFor(u => u.LastName)
                @Html.TextBoxFor(u => u.LastName, new { @class = "form-control" })
            </div>

            <div class="form-group">
                @Html.LabelFor(u => u.DisplayName)
                @Html.TextBoxFor(u => u.DisplayName, new { @class = "form-control" })
            </div>

            <div class="form-group">
                @Html.LabelFor(u => u.Email)
                @Html.TextBoxFor(u => u.Email, new { @class = "form-control" })
            </div>

            <div class="form-group">
                @Html.LabelFor(u => u.ImgUrl)
                @Html.TextBoxFor(u => u.ImgUrl, new { @class = "form-control" })
            </div>

            if (@Model.UserId != null)
            {
                <div class="form-group">
                    @Html.DropDownListFor(u => u.Role, new SelectList(Model.Roles, null, null), Model.Role, new { @class = "form-control" })
                </div>
            }
            else
            {
                <div class="form-group">
                    @Html.DropDownListFor(u => u.Role, new SelectList(Model.Roles, null, null), "--Select Role--", new { @class = "form-control" })
                </div>
            }

            <input type="hidden" value="@Model.UserId" name="userName" />
            <input type="submit" class="btn btn-info" value="Upate/Create User" />
        }

        @if (Model.Role == "Client" || Model.Role == "Admin")
        {
            if (@Model.AssignedCoach.DisplayName != null)
            {
                @Html.LabelFor(c => c.AssignedCoach)<br />
                @Html.TextBoxFor(c => c.AssignedCoach.DisplayName, new { @class = "form-control", @readonly = "readonly" })
            }

            if (@Model.AssignedCoach.DisplayName == null)
            {
                <p> Assign Coach to Client</p>

                using (Html.BeginForm("AssignCoach", "User", FormMethod.Post, new { @id = "assignCoachForm" }))
                {
                    <div class="form-group">
                        @Html.DropDownListFor(c => c.AssignCoachId, new SelectList(Model.Coaches, "UserId", "DisplayName"), "- Select Coach -", new { @class = "form-control" })
                    </div>

                    <input type="hidden" value="@Model.UserId" name="userId" />
                    <input type="submit" class="btn btn-info" value="Assign Coach" />
                }
            }
        }


    </div>
</center>










                




